package week2.validator_ex;

import java.io.FileInputStream;
import java.io.IOException;
import java.util.Properties;

public class AuthenticatorFactory {


    public static Authenticator createAuthenticator() {
    createKeyValueKeeper keeper =createKeyValueKeeper();
    Encrypter encrypter = createEncrypter();
 return  new Authenticator(keeper,encrypter);
    }

    private static KeyValueKeeper createKeyValueKeeper();Properties prop = new Properties();
    static {
        try {
            prop.load(new FileInputStream("week2/validator_ex/auth.properties"));
        } catch (IOException e) {
            e.printStackTrace();
        }
    }

    private static Encrypter createEncrypter() {

        Operation op = null;
        try {
            op = (Operation) Class.forName(prop.getProperty("opName")).newInstance();
        } catch (Exception e) {
            e.printStackTrace();
        }
        return op;
    }
}